package com.hgyc.mom.mes.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hgyc.mom.common.enums.CommonStatus;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hgyc.mom.mes.mapper.SopSendRecordMapper;
import com.hgyc.mom.mes.entity.SopSendRecord;
import com.hgyc.mom.mes.service.SopSendRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.hgyc.mom.common.exception.BizException;
import org.springframework.util.CollectionUtils;

/**
 * 推送记录 Service业务层实现
 *
 * @author fwj
 * @since 2025-06-27
 */
@Slf4j
@Service
public class SopSendRecordServiceImpl extends ServiceImpl<SopSendRecordMapper, SopSendRecord> implements SopSendRecordService {

    @Override
    public void saveRecord(SopSendRecord sopSendRecord) {
        // TODO 其他逻辑
        save(sopSendRecord);
    }

    @Override
    public void updateRecord(SopSendRecord sopSendRecord) {
        // TODO 其他逻辑
        updateById(sopSendRecord);
    }

    @Override
    public void removeRecord(List<Long> ids) {
        // TODO 其他逻辑
        removeByIds(ids);
    }

    @Override
    public void invalidByIp(String ip) {
        LambdaUpdateWrapper<SopSendRecord> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.eq(SopSendRecord::getIp, ip);
        updateWrapper.set(SopSendRecord::getStatus, CommonStatus.DISABLE.getValue().toString());

        update(updateWrapper);
    }
}
